<section id="main-content">
	<section class="wrapper">
		<!--state overview start-->
		<div class="row first">
			<div class="col-lg-12">
				<!-- 数据概览 icon:数据加载更新 报表下载-->

				<!--
          项目总和 list:项目总和（关注项目类、销售类、研发类、部门类、其他类）
          项目分部地区 （东北地区、西北地区、西南地区、华南地区、华中地区、华北地区、华东地区）
          项目收入总预测
          项目回款总和
          项目消费总预测 （客户交际费用、差旅费用、采购费用、其他费用）
          项目消费总和（线索阶段、立项阶段、合同阶段、交付阶段、回款阶段）
        -->

				<!-- 数据概览 -->
				<!-- <section class="panel">
                    <div class="view-header" style="margin:0;">
                        <div class="view-search" style="margin:0;">
                            <label class="pull-left" style="margin:0;">年份：</label>
                            <select id="searchYear" class="form-control pro-sech">
                                <option value="2018">2018年</option>
                                <option value="2019">2019年</option>
                                <option value="2020">2020年</option>
                                <option value="2021">2021年</option>
                                <option value="2022">2022年</option>
                                <option value="2023">2023年</option>
                                <option value="2024">2024年</option>
                                <option value="2025">2025年</option>
                                <option value="2026">2026年</option>
                                <option value="2027">2027年</option>
                                <option value="2028">2028年</option>
                            </select>

                            <label class="pull-left" style="margin:0;">项目名称：</label>
                            <input type="text" id="search" class="form-control pro-sech" style="max-width: 300px;"
                                placeholder="请输入项目名称">
                            <input type="hidden" id="proId" value="" />
                            <button class="btn btn-info searchbars" ng-click="search2()"
                                style="margin:0;margin-top:-3px;padding: 5px 12px;">搜索</button>
                        </div>
                    </div>
                </section> -->



				<section class="panel">
					<div class="panel-body" style="padding-bottom: 0;">
						<div class="row">
							<div class="col-lg-2">
								<div class="input-group m-bot15">
									<span class="input-group-addon" style="position: relative;z-index: 2;">年份</span>
									<select class="form-control" style="position: relative;margin-left:-4px;text-indent:4px;"
										id="searchYear">
										<option value="2018">2018年</option>
										<option value="2019">2019年</option>
										<option value="2020">2020年</option>
										<option value="2021">2021年</option>
										<option value="2022">2022年</option>
										<option value="2023">2023年</option>
										<option value="2024">2024年</option>
										<option value="2025">2025年</option>
										<option value="2026">2026年</option>
										<option value="2027">2027年</option>
										<option value="2028">2028年</option>
									</select>
								</div>
							</div>
							<div class="col-lg-4">
								<div class="input-group m-bot15">
									<span class="input-group-addon">项目名称</span>
									<input type="text" id="search" class="form-control pro-sech"
										style="border-top-right-radius: 4px;border-bottom-right-radius: 4px;" placeholder="请输入项目名称">
									<input type="hidden" id="proId" value="" />
								</div>
							</div>
							<div class="col-lg-3">
								<button class="btn btn-info searchbars" style="margin-bottom:15px;" ng-click="search2()">搜索</button>
							</div>
						</div>
					</div>
				</section>


				<div class="row">
					<div class="col-lg-5">
						<section class="panel">
							<header class="panel-heading">
								项目信息
							</header>
							<div class="panel-body">
								<div class="bio-row line-row">
									<p><span>项目名称 </span><a href="javascript:showProInfo()">{{proName}}</a></p>
								</div>
								<div class="bio-row">
									<p><span>项目类型 </span>{{proType}}</p>
								</div>
								<div class="bio-row">
									<p><span>当前状态 </span>{{proState}}</p>
								</div>
								<div class="bio-row">
									<p><span>当前阶段 </span>{{proStage}}</p>
								</div>
								<div class="bio-row">
									<p><span>项目经理 </span>{{proMgName}}</p>
								</div>
								<div class="bio-row">
									<p><span>优先级 </span>{{proLv}}</p>
								</div>
							</div>
						</section>
						<section class="panel">
							<header class="panel-heading">
								收入回款情况
							</header>
							<div class="weather-category">
								<ul>
									<li>
										<h5>{{proDtStage}}收入</h5>
										￥{{kpandhkmoney}}元
									</li>
									<li>
										<h5>已开票总额</h5>
										￥{{kptotalMoney}}元
									</li>
									<li>
										<h5>已回款总额</h5>
										￥{{hktotalMoney}}元
									</li>
								</ul>
							</div>
						</section>
					</div>
					<div class="col-lg-7">
						<section class="panel">
							<header class="panel-heading  ">
								项目预估收入按阶段分布
								<i class="add-icon">实时刷新</i>
							</header>
							<div class="panel-body">
								<div id="main9" style="width:100%;height:283px;"></div>
							</div>
						</section>
					</div>
				</div>



				<section class="panel">
					<header class="panel-heading">
						项目总成本：￥<span id="proMoney"></span>元
						<div class="pull-right hed-msg">
							<i class="icon-tag"> 此处项目总成本统计未包括商用采购费用和产品研发成本</i>
						</div>
					</header>
					<div class="panel-body">
						<ul class="ft-link">
							<li>
								<a href="javascript:;">
									<h5>人力总成本</h5>
									￥{{totalMoney}}元
								</a>
							</li>
							<li>
								<a href="javascript:;">
									<h5>非商用采购费用</h5>
									￥{{cgtotalMoney}}元
								</a>
							</li>
							<li>
								<a href="javascript:;">
									<h5>出差报销总费用</h5>
									￥{{bxtotalMoney}}元
								</a>
							</li>
							<li>
								<a href="javascript:;">
									<h5>折旧总费用</h5>
									￥{{totalzjMoney}}元
								</a>
							</li>
							<li>
								<a href="javascript:;">
									<h5>现金报销总费用</h5>
									￥0元
								</a>
							</li>
							<li>
								<a href="javascript:;">
									<h5>招待报销总费用</h5>
									￥0元
								</a>
							</li>
							<li>
								<a href="javascript:;" class="text-danger">
									<h5>商用采购费用</h5>
									￥{{cgsymoney}}元
								</a>
							</li>
						</ul>
					</div>
				</section>

				<div class="row">
					<div class="col-lg-6">
						<section class="panel">
							<header class="panel-heading  ">
								项目人力投入和人力费用按月分布
								<i class="add-icon">更新于昨晚24点</i>
							</header>
							<div class="panel-body">
								<div id="main2" style="width:100%;height:400px;"></div>
							</div>
						</section>
					</div>
					<div class="col-lg-6">
						<section class="panel">
							<header class="panel-heading  ">
								项目开票和回款按月分布
								<i class="add-icon">实时刷新</i>
							</header>
							<div class="panel-body">
								<div id="main8" style="width:100%;height:400px;"></div>
							</div>
						</section>
					</div>
				</div>

				<section class="panel">
					<header class="panel-heading  ">
						项目出差类型报销总费用按月分布
						<i class="add-icon">实时刷新</i>
					</header>
					<div class="panel-body">
						<div id="main6" style="width:100%;height:362px;"></div>
					</div>
				</section>

				<section class="panel">
					<header class="panel-heading">
						项目采购预测和实际费用按月分布
						<span class="label label-success pull-right ">实际非商用采购总费用：￥{{cgtotalMoney}}元</span>
						<span class="label label-info pull-right mr-5">实际商用采购总费用：￥{{cgsymoney}}元</span>
					</header>
					<div class="panel-body">
						<div id="main10" style="width:100%;height:362px;"></div>
					</div>
				</section>
				<div class="row">
					<div class="col-lg-6">
						<section class="panel">
							<header class="panel-heading">
								资产折旧费用按月分布
								<i class="add-icon">实时刷新</i>
							</header>
							<div class="panel-body">
								<div id="main7" style="width:100%;height:400px;"></div>
							</div>
						</section>
					</div>
					<div class="col-lg-6">
						<section class="panel">
							<header class="panel-heading">
								项目出差总费用（预测和实际）按月分布
								<span class="label label-danger pull-right">出差总费用：{{totalBuss}}元</span>
							</header>
							<div class="panel-body">
								<div id="main4" style="width:100%;height:400px;"></div>
							</div>
						</section>
					</div>
				</div>
				<div class="row">
					<div class="col-lg-6">
						<section class="panel">
							<header class="panel-heading">
								项目人力投入和人力费用按项目阶段分布
								<i class="add-icon">实时刷新</i>
							</header>
							<div class="panel-body">
								<div id="main1" style="width:100%;height:400px;"></div>
							</div>
						</section>
					</div>
					<div class="col-lg-6">
						<section class="panel">
							<header class="panel-heading  ">
								项目出差总费用（预测和实际）按项目阶段分布
								<i class="add-icon">更新于昨晚24点</i>
							</header>
							<div class="panel-body">
								<div id="main5" style="width:100%;height:400px;"></div>
							</div>
						</section>
					</div>
				</div>
			</div>
		</div>
		<!--state overview end-->
		<!--项目详情页-->
		<div class="two" ng-include="'lproinfo/lproinfo.html'"></div>
	</section>
</section>


<!-- echarts组件 -->
<script type="text/javascript" src="assets/echarts/echarts.min.js"></script>
<script type="text/javascript" src="js/autocomplete/jquery.autocomplete.js"></script>
<script>
	function findProData($scope, CertusFormAjax, $q) {
		var date = new Date;
		var year = date.getFullYear();
		$("#searchYear").val(year);

		$scope.proDtStage = "当前阶段";
		CertusFormAjax.ajax("isCrcd", {
			"code": "XMTB"
		}, function (response) {
			var data = JSON.parse(response.data);
			deptIds = data.deptCode;
			compIds = data.comanyCode;
			if (data.comanyCode != "") {
				CertusFormAjax.ajax("companyListByCode", { "code": data.comanyCode }, function (response) {
					$scope.comp = JSON.parse(response.data);
				});
				CertusFormAjax.ajax("findCdPros", { "compIds": data.comanyCode, "deptIds": deptIds }, function (response) {
					var nhlTeams = [];
					var data = response.data;
					for (var i = 0; i < data.length; i++) {
						var arr = {};
						arr.name = data[i].proName;
						arr.id = data[i].id;
						nhlTeams.push(arr);
					}
					//自动补全
					var nhl = $.map(nhlTeams, function (obj) {
						return {
							value: obj.name,
							data: {
								category: obj.id
							}
						};
					});
					// Initialize autocomplete with local lookup:
					$('#search').devbridgeAutocomplete({
						lookup: nhl,
						minChars: 1,
						onSelect: function (suggestion) {
							$("#proId").val(suggestion.data.category);
						},
						showNoSuggestionNotice: true,
						noSuggestionNotice: 'Sorry, no matching results'
					});

				});
			}
		});
		//查询项目基本信息
		this.showProInfo = function () {
			var proId = $("#proId").val();
			$scope.proId = proId;
			probox($scope, CertusFormAjax);
		}

		$scope.search2 = function () {
			var year = $("#searchYear").val();

			var proId = $("#proId").val();
			if (proId == "") {
				layer.msg("请选择正确的项目名称或您无权限查看该项目");
				return;
			}
			searchProInfo(proId);
			monthTjs(proId, year, "");
			bussesPhasTjs(proId, year, "");
			bugetTjs(proId, year, "");
			phaseTjs(proId, year, ""),
				bussesMTjs(proId, year, ""),
				bussesType(proId, year, ""),
				assetMs(proId, year, ""),
				cgTjs(proId, year, ""),
				kpAndHkTjs(proId, year, "")
			$q.all([
				phaseTjs(proId, year, ""),
				bussesMTjs(proId, year, ""),
				bussesType(proId, year, ""),
				assetMs(proId, year, ""),
				cgTjs(proId, year, ""),
				kpAndHkTjs(proId, year, "")
			]);

            setTimeout(function () {
                var proMoney = $scope.totalMoney +
                    $scope.cgMoney + $scope.bxtotalMoney +
                    $scope.totalzjMoney;
                $("#proMoney").html(proMoney);
            },500);
		};

		this.searchProInfo = function (proId) {
			CertusFormAjax.ajax("findProInfo", {
				"proId": proId
			}, function (response) {
				var data = response.data;
				var content = "";
				if (data.proType == "XS") {
					content = '销售类';
				} else if (data.proType == "ZL") {
					content = '战略类';
				} else if (data.proType == "YF") {
					content = '研发类';
				} else if (data.proType == "BM") {
					content = '部门类';
				} else if (data.proType == "SW") {
					content = '事务类';
				} else {
					content = '测试类';
				}
				$scope.proName = data.proName;
				$scope.proType = content;
				if (data.proState == "1") {
					$scope.proState = "运行中";
				} else if (data.proState == "2") {
					$scope.proState = "已关闭";
				} else if (data.proState == "3") {
					$scope.proState = "已完结";
				} else {
					$scope.proState = "已暂停";
				}
				$scope.proMgName = data.userName;
				$scope.proStage = data.proStage;
				$scope.proDtStage = data.proStage;

				if (data.proLv == 1) {
					$scope.proLv = '低';
				}
				if (data.proLv == 2) {
					$scope.proLv = '中';
				}
				if (data.proLv == 3) {
					$scope.proLv = '高';
				}
				$scope.proJz = data.proJz;
				$scope.stageCode = data.stageCode;
			});
		}
		this.phaseTjs = function (proId, year, compCode) {
			var totalRt = 0;
			var totalMoney = 0;
			CertusFormAjax.ajax('findPhaseTjs', {
				"param": proId, "year": year, "compCode": compCode
			}, function (response) {
				;
				var data = response.data;
				var yccost = [];
				var sjcost = [];
				var ycrt = [];
				var sjrt = [];

				for (var i = 0; i < data.length; i++) {
					totalRt += data[i].actualday;
					totalMoney += data[i].actualcost;
					if (data[i].phase == "XS") {
						yccost[0] = data[i].forecastcost;
						sjcost[0] = data[i].actualcost;
						ycrt[0] = data[i].forecastday;
						sjrt[0] = data[i].actualday;
					} else if (data[i].phase == "LX") {
						yccost[1] = data[i].forecastcost;
						sjcost[1] = data[i].actualcost;
						ycrt[1] = data[i].forecastday;
						sjrt[1] = data[i].actualday;
					} else if (data[i].phase == "TB") {
						yccost[2] = data[i].forecastcost;
						sjcost[2] = data[i].actualcost;
						ycrt[2] = data[i].forecastday;
						sjrt[2] = data[i].actualday;
					} else if (data[i].phase == "JF") {
						yccost[3] = data[i].forecastcost;
						sjcost[3] = data[i].actualcost;
						ycrt[3] = data[i].forecastday;
						sjrt[3] = data[i].actualday;
					} else {
						yccost[4] = data[i].forecastcost;
						sjcost[4] = data[i].actualcost;
						ycrt[4] = data[i].forecastday;
						sjrt[4] = data[i].actualday;
					}
				}
				$scope.totalRt = totalRt;
				$scope.totalMoney = totalMoney;
				var myChart1 = echarts.init(document.getElementById('main1'));
				option = {
					tooltip: {
						trigger: 'axis',
						axisPointer: {
							type: 'cross',
							crossStyle: {
								color: '#999'
							}
						}
					},
					toolbox: {
						feature: {
							dataView: {
								show: true,
								readOnly: true,
								optionToContent: function (opt) {
									//console.info(opt);
									var axisData = opt.xAxis[0].data;
									var series = opt.series;
									var tdHeaders = '<td>阶段</td>'; //表头
									series.forEach(function (item) {
										tdHeaders += '<td>' + item.name + '</td>'; //组装表头
									});
									var table = '<div class="table-responsive"><table class="table table-bordered table-striped table-hover" style="text-align:center"><tbody><tr>' + tdHeaders + '</tr>';
									var tdBodys = ''; //数据
									for (let i = 0, l = axisData.length; i < l; i++) {
										for (let j = 0; j < series.length; j++) {
											tdBodys += '<td>' + series[j].data[i] + '</td>'; //组装表数据
										}
										table += '<tr><td style="padding: 0 10px">' + axisData[i] + '</td>' + tdBodys + '</tr>';
										tdBodys = '';
									}

									table += '</tbody></table></div>';
									return table;
								}
							},
							magicType: {
								show: true,
								type: ['line', 'bar']
							},
							restore: {
								show: true
							},
							saveAsImage: {
								show: false
							}
						}
					},
					grid: {
						left: '3%',
						right: '4%',
						bottom: '3%',
						containLabel: true
					},
					legend: {
						data: ['预测成本', '实际成本', '预测人天', '实际人天'],
						left: 50
					},
					xAxis: [{
						type: 'category',
						data: ['线索', '运作', '合同', '交付', '回款'],
						axisPointer: {
							type: 'shadow'
						}
					}],
					yAxis: [{
						type: 'value',
						name: '元',
						axisLabel: {
							formatter: '￥{value}'
						}
					},
					{
						type: 'value',
						name: '人/天',
						axisLabel: {
							formatter: '{value}'
						}
					}
					],
					series: [{
						name: '预测成本',
						type: 'bar',
						data: yccost
					},
					{
						name: '实际成本',
						type: 'bar',
						data: sjcost
					},
					{
						name: '预测人天',
						type: 'line',
						yAxisIndex: 1,
						data: ycrt
					},
					{
						name: '实际人天',
						type: 'line',
						yAxisIndex: 1,
						data: sjrt
					}
					]
				};
				myChart1.setOption(option);
				return $scope;
			});
		};
		this.monthTjs = function (proId, year, compCode) {
			CertusFormAjax.ajax('findMonthTjs', {
				"param": proId, "year": year, "compCode": compCode
			}, function (response) {
				var data = response.data;
				var yccost = [];
				var sjcost = [];
				var ycrt = [];
				var sjrt = [];
				for (var i = 0; i < data.length; i++) {
					yccost[i] = data[i].yccost;
					sjcost[i] = data[i].sjcost;
					ycrt[i] = data[i].ycpercent / 100;
					sjrt[i] = data[i].sjpercent / 100;
				}
				var myChart2 = echarts.init(document.getElementById('main2'));
				option = {
					tooltip: {
						trigger: 'axis',
						axisPointer: {
							type: 'cross',
							crossStyle: {
								color: '#999'
							}
						}
					},
					toolbox: {
						feature: {
							dataView: {
								show: true,
								readOnly: true,
								optionToContent: function (opt) {
									//console.info(opt);
									var axisData = opt.xAxis[0].data;
									var series = opt.series;
									var tdHeaders = '<td>时间</td>'; //表头
									series.forEach(function (item) {
										tdHeaders += '<td>' + item.name + '</td>'; //组装表头
									});
									var table = '<div class="table-responsive"><table class="table table-bordered table-striped table-hover" style="text-align:center"><tbody><tr>' + tdHeaders + '</tr>';
									var tdBodys = ''; //数据
									for (let i = 0, l = axisData.length; i < l; i++) {
										for (let j = 0; j < series.length; j++) {
											tdBodys += '<td>' + series[j].data[i] + '</td>'; //组装表数据
										}
										table += '<tr><td style="padding: 0 10px">' + axisData[i] + '</td>' + tdBodys + '</tr>';
										tdBodys = '';
									}

									table += '</tbody></table></div>';
									return table;
								}
							},
							magicType: {
								show: true,
								type: ['line', 'bar']
							},
							restore: {
								show: true
							},
							saveAsImage: {
								show: false
							}
						}
					},
					grid: {
						left: '3%',
						right: '4%',
						bottom: '3%',
						containLabel: true
					},
					legend: {
						data: ['预测成本', '实际成本', '预测人天', '实际人天'],
						left: 50
					},
					xAxis: [{
						type: 'category',
						data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月',
							'11月', '12月'
						],
						axisPointer: {
							type: 'shadow'
						}
					}],
					yAxis: [{
						type: 'value',
						name: '元',
						axisLabel: {
							formatter: '￥{value}'
						}
					},
					{
						type: 'value',
						name: '人/天',
						axisLabel: {
							formatter: '{value}'
						}
					}
					],
					series: [{
						name: '预测成本',
						type: 'bar',
						data: yccost
					},
					{
						name: '实际成本',
						type: 'bar',
						data: sjcost
					},
					{
						name: '预测人天',
						type: 'line',
						yAxisIndex: 1,
						data: ycrt
					},
					{
						name: '实际人天',
						type: 'line',
						yAxisIndex: 1,
						data: sjrt
					}
					]
				};
				myChart2.setOption(option);
			});
		}


		this.bussesMTjs = function (proId, year, compCode) {
			CertusFormAjax.ajax('findBussesTjs', {
				"param": proId, "year": year, "compCode": compCode
			}, function (response) {
				;
				var data = response.data;
				var bugetlist = data.nbugetList;
				var treimlist = data.ntreimList;
				var yccost = [];
				var sjcost = [];
				var totalBussMoney = 0;
				for (var i = 0; i < bugetlist.length; i++) {
					yccost[i] = bugetlist[i].ycbuget;
				}
				for (var i = 0; i < treimlist.length; i++) {
					sjcost[i] = treimlist[i].totalMoney;
					totalBussMoney += treimlist[i].totalMoney;
				}
				$scope.totalBuss = totalBussMoney;
				var myChart2 = echarts.init(document.getElementById('main4'));
				option = {
					tooltip: {
						trigger: 'axis'
					},
					legend: {
						data: ['预测费用', '实际费用']
					},
					grid: {
						left: '3%',
						right: '4%',
						bottom: '3%',
						containLabel: true
					},
					toolbox: {
						feature: {
							saveAsImage: {}
						}
					},
					xAxis: {
						type: 'category',
						boundaryGap: false,
						data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月',
							'12月'
						]
					},
					yAxis: {
						type: 'value'
					},
					series: [{
						name: '预测费用',
						type: 'line',
						data: yccost
					},
					{
						name: '实际费用',
						type: 'line',
						data: sjcost
					}
					]
				};

				myChart2.setOption(option);
				return $scope;
			});
		}

		this.bussesPhasTjs = function (proId, year, compCode) {
			CertusFormAjax.ajax('findBussesPhasTjs', {
				"param": proId, "year": year, "compCode": compCode
			}, function (response) {
				var data = response.data;
				var bugetlist = data.bugetList;
				var treimDays = data.treimDays;
				var yccost = [];
				var sjcost = [];
				for (var i = 0; i < bugetlist.length; i++) {
					yccost[i] = bugetlist[i].buget;
				}
				for (var i = 0; i < treimDays.length; i++) {
					if (treimDays[i].phase == "XS") {
						sjcost.push(treimDays[i].cost);
					} else if (treimDays[i].phase == "LX") {
						sjcost.push(treimDays[i].cost);
					} else if (treimDays[i].phase == "TB") {
						sjcost.push(treimDays[i].cost);
					} else if (treimDays[i].phase == "JF") {
						sjcost.push(treimDays[i].cost);
					} else {
						sjcost.push(treimDays[i].cost);
					}
				}
				var myChart2 = echarts.init(document.getElementById('main5'));
				option = {
					tooltip: {
						trigger: 'axis'
					},
					legend: {
						data: ['预测费用', '实际费用']
					},
					grid: {
						left: '3%',
						right: '4%',
						bottom: '3%',
						containLabel: true
					},
					toolbox: {
						feature: {
							saveAsImage: {}
						}
					},
					xAxis: {
						type: 'category',
						boundaryGap: false,
						data: ["线索", "运作", "合同", "交付", "回款"]
					},
					yAxis: {
						type: 'value'
					},
					series: [{
						name: '预测费用',
						type: 'line',
						data: yccost
					},
					{
						name: '实际费用',
						type: 'line',
						data: sjcost
					}
					]
				};

				myChart2.setOption(option);
			});
		}
		this.bussesType = function (proId, year, compCode) {
			CertusFormAjax.ajax('findMBusessTypeByPro', {
				"param": proId, "year": year, "compCode": compCode
			}, function (response) {
				;
				var data = response.data;
				var bxtotalMoney = 0;
				var trains = [];
				var plans = [];
				var traffics = [];
				var hotels = [];
				var repetitions = [];
				var others = [];
				var travelAllowances = [];
				var fmonth = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
				for (var i = 0; i < data.length; i++) {
					var code = data[i].tri_class_code;
					var emonth = data[i].month;
					var name = data[i].totalMoney;
					bxtotalMoney += data[i].totalMoney;
					if (code == "train") {
						for (var j = 0; j < fmonth.length; j++) {
							if (emonth == fmonth[j]) {
								trains.push(name);
							}
						}
					} else if (code == "plan") {
						for (var j = 0; j < fmonth.length; j++) {
							if (emonth == fmonth[j]) {
								plans.push(name);
							}
						}
					} else if (code == "traffic") {
						for (var j = 0; j < fmonth.length; j++) {
							if (emonth == fmonth[j]) {
								traffics.push(name);
							}
						}
					} else if (code == "hotel") {
						for (var j = 0; j < fmonth.length; j++) {
							if (emonth == fmonth[j]) {
								hotels.push(name);
							}
						}
					} else if (code == "repetition") {
						for (var j = 0; j < fmonth.length; j++) {
							if (emonth == fmonth[j]) {
								repetitions.push(name);
							}
						}
					} else if (code == "others") {
						for (var j = 0; j < fmonth.length; j++) {
							if (emonth == fmonth[j]) {
								others.push(name);
							}
						}
					} else {
						for (var j = 0; j < fmonth.length; j++) {
							if (emonth == fmonth[j]) {
								travelAllowances.push(name);
							}
						}
					}
				}
				$scope.bxtotalMoney = bxtotalMoney;
				var myChart2 = echarts.init(document.getElementById('main6'));
				option = {
					tooltip: {
						trigger: 'axis',
						axisPointer: { // 坐标轴指示器，坐标轴触发有效
							type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
						}
					},
					legend: {
						data: ['火车/汽车', '飞机', '交通费用', '住宿费用', '招待费', '其他费用', '出差补助']
					},
					grid: {
						left: '3%',
						right: '4%',
						bottom: '3%',
						containLabel: true
					},
					xAxis: [{
						type: 'category',
						data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月',
							'11月', '12月'
						]
					}],
					yAxis: [{
						type: 'value'
					}],
					series: [{
						name: '火车/汽车',
						type: 'bar',
						barWidth: 30,
						stack: '各类出差报销',
						data: trains
					},
					{
						name: '飞机',
						type: 'bar',
						stack: '各类出差报销',
						data: plans
					},
					{
						name: '交通费用',
						type: 'bar',
						stack: '各类出差报销',
						data: traffics
					},
					{
						name: '住宿费用',
						type: 'bar',
						stack: '各类出差报销',
						data: hotels
					},
					{
						name: '招待费',
						type: 'bar',
						stack: '各类出差报销',
						data: repetitions
					},
					{
						name: '其他费用',
						type: 'bar',
						stack: '各类出差报销',
						data: others
					},
					{
						name: '出差补助',
						type: 'bar',
						stack: '各类出差报销',
						data: travelAllowances
					}
					]
				};
				myChart2.setOption(option);
				return $scope;
			});
		};

		this.assetMs = function (proId, year, compCode) {
			CertusFormAjax.ajax('findAssetMs', {
				"param": proId, "year": year, "compCode": compCode
			}, function (response) {
				var data = response.data;
				var moneys = [];
				var totalMoney = 0;
				for (var i = 0; i < data.length; i++) {
					moneys.push(data[i].totalMoney);
					totalMoney += data[i].totalMoney;
				}
				$scope.totalzjMoney = totalMoney;
				var myChart2 = echarts.init(document.getElementById('main7'));
				option = {
					color: ['#3398DB'],
					tooltip: {
						trigger: 'axis',
						axisPointer: { // 坐标轴指示器，坐标轴触发有效
							type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
						}
					},
					legend: {
						data: ['资产折旧费用']
					},
					grid: {
						left: '3%',
						right: '4%',
						bottom: '3%',
						containLabel: true
					},
					xAxis: [{
						type: 'category',
						data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月',
							'11月', '12月'
						],
						axisTick: {
							alignWithLabel: true
						}
					}],
					yAxis: [{
						type: 'value'
					}],
					series: [{
						name: '资产折旧费用',
						type: 'bar',
						barWidth: '60%',
						data: moneys
					}]
				};
				myChart2.setOption(option);
				return $scope;
			})
		};

		//开票和回款按月统计
		this.kpAndHkTjs = function (proId, year, compCode) {
			CertusFormAjax.ajax('findPayTjs', {
				"param": proId, "year": year, "compCode": compCode
			}, function (response) {
				var payList = response.data.payList;
				var invoiceList = response.data.invoiceList;
				var kpbuget = [];
				var hkbuget = [];
				var kptotalMoney = 0;
				var hktotalMoney = 0;
				for (var i = 0; i < invoiceList.length; i++) {
					kpbuget.push(invoiceList[i].buget);
					hktotalMoney += invoiceList[i].buget;
				}
				for (var i = 0; i < payList.length; i++) {
					hkbuget.push(payList[i].buget);
					kptotalMoney += payList[i].buget;
				}
				$scope.kpandhkmoney = kptotalMoney + hktotalMoney;
				$scope.kptotalMoney = kptotalMoney;
				$scope.hktotalMoney = hktotalMoney;
				var myChart2 = echarts.init(document.getElementById('main8'));
				option = {
					tooltip: {
						trigger: 'axis',
						axisPointer: {
							type: 'cross',
							crossStyle: {
								color: '#999'
							}
						}
					},
					toolbox: {
						feature: {
							dataView: {
								show: true,
								readOnly: true,
								optionToContent: function (opt) {
									var axisData = opt.xAxis[0].data;
									var series = opt.series;
									var tdHeaders = '<td>时间</td>'; //表头
									series.forEach(function (item) {
										tdHeaders += '<td>' + item.name + '</td>'; //组装表头
									});
									var table = '<div class="table-responsive"><table class="table table-bordered table-striped table-hover" style="text-align:center"><tbody><tr>' + tdHeaders + '</tr>';
									var tdBodys = ''; //数据
									for (let i = 0, l = axisData.length; i < l; i++) {
										for (let j = 0; j < series.length; j++) {
											tdBodys += '<td>' + series[j].data[i] + '</td>'; //组装表数据
										}
										table += '<tr><td style="padding: 0 10px">' + axisData[i] + '</td>' + tdBodys + '</tr>';
										tdBodys = '';
									}

									table += '</tbody></table></div>';
									return table;
								}
							},
							magicType: {
								show: true,
								type: ['line', 'bar']
							},
							restore: {
								show: true
							},
							saveAsImage: {
								show: false
							}
						}
					},
					grid: {
						left: '3%',
						right: '4%',
						bottom: '3%',
						containLabel: true
					},
					legend: {
						data: ['开票费用', '回款费用']
					},
					xAxis: [{
						type: 'category',
						data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月',
							'11月', '12月'
						],
						axisPointer: {
							type: 'shadow'
						}
					}],
					yAxis: [{
						type: 'value',
						name: '元',
						axisLabel: {
							formatter: '￥{value}'
						}
					}],
					series: [{
						name: '开票费用',
						type: 'bar',
						data: kpbuget
					},
					{
						name: '回款费用',
						type: 'bar',
						data: hkbuget
					}
					]
				};
				myChart2.setOption(option);
			});
		};

		//按阶段统计预估费用
		this.bugetTjs = function (proId, year, compCode) {
			CertusFormAjax.ajax('findBugetTjs', {
				"param": proId, "year": year, "compCode": compCode
			}, function (response) {
				var data = response.data;
				var bugets = data.bugets;
				var yccost = [];
				for (var i = 0; i < bugets.length; i++) {
					if (bugets[i].phase_code == "XS") {
						yccost.push(bugets[0].buget);
					} else {
						yccost.push(bugets[1].buget);
					}
				}
				var tbs = data.tbs;
				yccost[2] = tbs.totalMoney;
				var hks = data.hts;
				yccost[3] = hks.totalMoney;
				var myChart2 = echarts.init(document.getElementById('main9'));
				option = {
					tooltip: {
						trigger: 'axis',
						axisPointer: {
							type: 'cross',
							crossStyle: {
								color: '#999'
							}
						}
					},
					toolbox: {
						feature: {
							dataView: {
								show: true,
								readOnly: true,
								optionToContent: function (opt) {
									var axisData = opt.xAxis[0].data;
									var series = opt.series;
									var tdHeaders = '<td>阶段</td>'; //表头
									series.forEach(function (item) {
										tdHeaders += '<td>' + item.name + '</td>'; //组装表头
									});
									var table = '<div class="table-responsive"><table class="table table-bordered table-striped table-hover" style="text-align:center"><tbody><tr>' + tdHeaders + '</tr>';
									var tdBodys = ''; //数据
									for (let i = 0, l = axisData.length; i < l; i++) {
										for (let j = 0; j < series.length; j++) {
											tdBodys += '<td>' + series[j].data[i] + '</td>'; //组装表数据
										}
										table += '<tr><td style="padding: 0 10px">' + axisData[i] + '</td>' + tdBodys + '</tr>';
										tdBodys = '';
									}

									table += '</tbody></table></div>';
									return table;

								}
							},
							magicType: {
								show: true,
								type: ['line', 'bar']
							},
							restore: {
								show: true
							},
							saveAsImage: {
								show: false
							}
						}
					},
					grid: {
						left: '0',
						bottom: '5%',
						containLabel: true
					},
					legend: {
						data: ['项目阶段预估收入'],
						left: 0,
					},
					xAxis: [{
						type: 'category',
						data: ['线索', '运作', '合同', '交付'],
						axisPointer: {
							type: 'shadow'
						}
					}],
					yAxis: [{
						type: 'value',
						name: '元',
						axisLabel: {
							formatter: '￥{value}'
						}
					}],
					series: [{
						name: '项目阶段预估收入',
						type: 'bar',
						barWidth: '20px',
						data: yccost,
						itemStyle: {
							normal: {
								color: '#8cb8be'
							}
						},
					}]
				};
				myChart2.setOption(option);
				return $scope;
			});
		};

		//项目采购按月分布
		this.cgTjs = function (proId, year, compCode) {
			CertusFormAjax.ajax('findCgTjs', {
				"param": proId, "year": year, "compCode": compCode
			}, function (response) {
				;
				var data = response.data;
				var yctjs = data.cgycs;
				var sjtjs = data.cgsjs;
				var ycsys = [];
				var yczys = [];
				var ycwls = [];
				var sjsys = [];
				var sjzys = [];
				var sjwls = [];
				var cgtotalMoney = 0;
				var cgsymoney = 0;
				for (var i = 0; i < yctjs.length; i++) {
					if (yctjs[i].code == "SY") {
						ycsys.push(yctjs[i].totalMoney);
					} else if (yctjs[i].code == "ZY") {
						yczys.push(yctjs[i].totalMoney);
					} else {
						ycwls.push(yctjs[i].totalMoney);
					}
				}
				for (var i = 0; i < sjtjs.length; i++) {
					if (sjtjs[i].code == "SY") {
						cgsymoney += yctjs[i].totalMoney;
						sjsys.push(yctjs[i].totalMoney);
					} else if (sjtjs[i].code == "ZY") {
						cgtotalMoney += yctjs[i].totalMoney;
						sjzys.push(yctjs[i].totalMoney);
					} else {
						cgtotalMoney += yctjs[i].totalMoney;
						sjwls.push(yctjs[i].totalMoney);
					}
				}
				$scope.cgtotalMoney = cgtotalMoney;
				$scope.cgsymoney = cgsymoney;
				var cgMoney = cgtotalMoney + cgsymoney;
				$scope.cgMoney = cgMoney;
				var myChart2 = echarts.init(document.getElementById('main10'));
				option = {
					tooltip: {
						trigger: 'axis',
						axisPointer: { // 坐标轴指示器，坐标轴触发有效
							type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
						}
					},
					legend: {
						data: ['预测商用', '预测自用', '预测外联', '实际商用', '实际自用', '实际外联']
					},
					grid: {
						left: '3%',
						right: '4%',
						bottom: '3%',
						containLabel: true
					},
					xAxis: [{
						type: 'category',
						data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月',
							'11月', '12月'
						]
					}],
					yAxis: [{
						type: 'value'
					}],
					series: [{
						name: '预测商用',
						type: 'bar',
						stack: '预测采购费用',
						data: ycsys
					},
					{
						name: '实际商用',
						type: 'bar',
						stack: '实际采购费用',
						data: sjsys
					},
					{
						name: '预测自用',
						type: 'bar',
						stack: '预测采购费用',
						data: yczys
					},
					{
						name: '实际自用',
						type: 'bar',
						stack: '实际采购费用',
						data: sjzys
					},
					{
						name: '预测外联',
						type: 'bar',
						stack: '预测采购费用',
						data: ycwls
					}, {
						name: '实际外联',
						type: 'bar',
						stack: '实际采购费用',
						data: sjwls
					}
					]
				};
				myChart2.setOption(option);
				return $scope;
			});
		};
	}
</script>